//---------------------------------------------------------------------------

#ifndef FrameProvidersFinanceH
#define FrameProvidersFinanceH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Db.hpp>
#include <DBTables.hpp>
#include <DBGrids.hpp>
#include <Grids.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
#include <ToolWin.hpp>
#include <DB.hpp>
#include "FrameProviderBridge.h"

//---------------------------------------------------------------------------
class TfrmFrameProvidersFinance : public TForm
{
__published:	// IDE-managed Components
        TDataSource *srcModels;
        TTable *tblModels;
        TDataSource *srcFirms;
        TTable *tblFirms;
        TPanel *pnlMain;
        TToolBar *ToolBar1;
        TToolButton *btnUpdateOrder;
        TToolButton *btnAddOrder;
        TToolButton *btnDeleteOrder;
        TBitBtn *btnClose;
        TBitBtn *btnHelp;
        TStringGrid *grdOrders;
        TLabel *lblOrdersAndCredits;
        TPanel *Panel1;
        TLabel *lblRefunds;
        TToolBar *ToolBar2;
        TToolButton *btnUpdateRefund;
        TToolButton *btnDeleteRefund;
        TStringGrid *grdRefunds;
        TLabel *lblTotalDebt;
        TLabel *lblTotalDebtValue;
        TToolButton *btnAddRefund;
        void __fastcall btnUpdateOrderClick(TObject *Sender);
        void __fastcall btnAddOrderClick(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall btnDeleteOrderClick(TObject *Sender);
        void __fastcall btnCloseClick(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall btnUpdateRefundClick(TObject *Sender);
        void __fastcall btnAddRefundClick(TObject *Sender);
        void __fastcall btnDeleteRefundClick(TObject *Sender);
private:	// User declarations
        TFrameProviderBridge* bridge;
        TFrameProvider* frameProvider;
        TStringList * orders;
        TStringList * refunds;

        void SetOrderButtonsState();
        void SetRefundButtonsState();
        void RefreshOrdersGrid();
        void RefreshRefundsGrid();
        void RefreshGrids();

        Currency GetTotalDebt();
        void ShowTotalDebt();
        
public:		// User declarations
        __fastcall TfrmFrameProvidersFinance(TComponent* Owner, TFrameProviderBridge* bridge, TFrameProvider* frameProvider);
};
#endif
